

CXX	:= g++
LD	:= g++
AR	:= ar
CXXFLAGS := -Wall -O2 -Werror
INCLUDES = -I../common

TARGET	= a.out

LINKS	= -L.
LIBS	= 

SOURCES := main.cc
SOURCES += auth.cc
SOURCES += mid_des_enc.cc
SOURCES += mid_set_key.cc
SOURCES += mid_md5.cc
SOURCES += ../common/tools/dump.cc
SOURCES += ../common/tools/socket.cc
SOURCES += ../common/tools/file_util.cc
SOURCES += ../common/tools/string_util.cc


OBJS := $(SOURCES:.cc=.o)
DEPS := $(SOURCES:.cc=.d)

all: prebuild $(TARGET)

$(TARGET): $(OBJS)
	@echo Linking $@ ...
	$(LD) $(OBJS) $(LINKS) $(LIBS) -o$@
	@echo -------------------------------------------
	@echo done.

.cpp.o:
	@echo Compling $@ ...
	$(CXX) -c $< $(INCLUDES) $(CXXFLAGS)  -o $@
	@echo -------------------------------------------

.cc.o:
	@echo Compling $@ ...
	$(CXX) -c $< $(INCLUDES) $(CXXFLAGS)  -o $@
	@echo ------------------------------------------

%.d:%.cc
	$(CXX) -MM $< $(INCLUDES) $(CXXFLAGS) -o $@

prebuild:
	#echo -------

include $(DEPS)

clean:
	rm -fr $(OBJS) $(DEPS) readlog.o wincurse.o



